---
- name: install gpg so we can import a key
  dnf: pkg=gpg state=present
  tags:
  - grafana
  - packages

- name: import gpg key
  rpm_key: state=present key=https://packagecloud.io/gpg.key

- name: import second gpg key
  rpm_key: state=present key=https://grafanarel.s3.amazonaws.com/RPM-GPG-KEY-grafana

- name: add repo
  copy: src=grafana.repo dest=/etc/yum.repos.d/grafana.repo
  tags:
  - grafana
  - packages
  - repo

- name: install grafana
  dnf: pkg=grafana state=present
  tags:
  - grafana
  - packages

- name: set sebool so apache can talk to grafana-server
  seboolean: name=httpd_can_network_connect
                    state=true
                    persistent=true

- name: Set grafana-server to run on boot
  service: name=grafana-server enabled=yes state=started
  tags:
  - service
  - grafana

- name: grafana apache proxy config file
  template: src=grafana.conf dest=/etc/httpd/conf.d/grafana.conf owner=root group=root mode=644
  notify:
  - restart apache
  tags:
  - grafana
  - config

- name: Install custom systemd service file
  copy: >
    src=grafana.service
    dest=/etc/systemd/system/grafana-server.service
  tags:
  - config
  - grafana
  notify:
  - restart grafana
